Ambient 8 Click
Ambient 8 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : MikroE Team
- Date : Dec 2019.
- Type : I2C type
Software Support
Example Description
This example collects data from the sensor, calculates the light intensity and then logs it.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Ambient8
Example Key Functions
- ambient8_cfg_setup Config Object Initialization function.
void ambient8_cfg_setup(ambient8_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition ambient8.h:164
- ambient8_init Initialization function.
AMBIENT8_RETVAL ambient8_init(ambient8_t *ctx, ambient8_cfg_t *cfg)
Initialization function.
Click ctx object definition.
Definition ambient8.h:148
- ambient8_default_cfg Click Default Configuration function.
- ambient8_set_constants This function sets constants ( gain and integration time ) for lux level calculation.
void ambient8_set_constants(ambient8_t *ctx)
Setting constants for lux level calculation.
- ambient8_get_als_data This function checks for new data by polling ALS status register.
AMBIENT8_RETVAL ambient8_get_als_data(ambient8_t *ctx, uint16_t *als_data_ch1, uint16_t *als_data_ch0)
Reading ALS data.
- This function reads and data and performs lux level calculation err_t ambient8_get_lux_level ( ambient8_t* ctx, float* lux_level, float window_factor, float IR_factor );
Application Init
Initializes device and I2C driver.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
window_factor = 1.0;
IR_factor = 0.0;
}
#define AMBIENT8_MAP_MIKROBUS(cfg, mikrobus)
Definition ambient8.h:67
void application_init(void)
Definition main.c:39
Application Task
Performs Lux calculation based on window and IR factor and log results.
{
if ( status_flag == 0 )
{
log_printf( &logger, "Lux level : %.2f lx\r\n", lux_level );
}
}
AMBIENT8_RETVAL ambient8_get_lux_level(ambient8_t *ctx, float *lux_level, float window_factor, float IR_factor)
Calculating lux level.
void application_task(void)
Definition main.c:67
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.